package com.inspectortime.util;

import java.text.DecimalFormat;

public class StringBufferUtils {
	
	private StringBufferUtils() {}
	
	public static void addNameValuePair(StringBuffer sb, String name, String valuePrefix, double value, String unit) {
		if (value == 0) {
			return;
		}
		DecimalFormat fmt = new DecimalFormat("#");
		addNameValuePair(sb, name, valuePrefix, fmt.format(value), unit);		
	}
	
	public static void addNameValuePair(StringBuffer sb, String name, String valuePrefix, Object value, String unit) {
		if (value == null) {
			return;
		}
		int  prevLen = sb.length();
		if (prevLen > 1) {
			sb.append(", ");
		}
		sb.append(name + "=" + valuePrefix + value + unit);
	}



}
